import _ from "lodash";
import {userType} from "./enum";
import {REG} from "./reg";

export const getPrice = (yPrice, coupon) => {
    const price = Number(yPrice) - Number(coupon || 0);
    return price.toFixed(2);
};

export const computedJF = (yPrice, ratio) => {
    const num = Number(ratio) / 10000;
    const price = Number(yPrice * num).toFixed(2);
    return price;
};

//获得图片url
export const getImgUrl = (url: string) => {
    if (REG.url.test(url)) {
        return url;
    } else {
        return "https:" + url;
    }
};
export const getUserType = value => _.find(userType, {value})?.title;
